class InvalidScoreError(Exception):
    pass

try:
    score  = int(input("请输入学生的成绩:"))
    if score < 0 or score > 100:
        raise  InvalidScoreError("输入无效,请输入一个有效的分数(0-100之间)。")

if score >= 90:
    grade = "优"
elif score >= 80:
    grade = "良"
elif score >= 70:
    grade = "中等"
elif score >= 60:
    grade = "及格"
else:
    grade = "不及格"

print("该学生的成绩为",grade)

except ValueError:
 print("输入无效,请输入一个有效的数字.")
except  InvalidScoreError as e:
      print("该学生的成绩等级为:",grade)